# coding: utf8

#########################################################################
## This scaffolding model makes your app work on Google App Engine too
#########################################################################

if request.env.web2py_runtime_gae:            # if running on Google App Engine
    db = DAL('gae')                           # connect to Google BigTable
    session.connect(request, response, db=db) # and store sessions and tickets there
    ### or use the following lines to store sessions in Memcache
    # from gluon.contrib.memdb import MEMDB
    # from google.appengine.api.memcache import Client
    # session.connect(request, response, db=MEMDB(Client())
else:                                         # else use a normal relational database
    db = DAL('sqlite://storage.sqlite')       # if not, use SQLite or other DB

from gluon.tools import *
mail=Mail()                                  # mailer
auth=Auth(globals(),db)                      # authentication/authorization
auth.settings.hmac_key='c0ec748d-d9e2-4b3e-a3b6-f283e3c4fddb'
auth.define_tables()                         # creates all needed tables
crud=Crud(globals(),db)                      # for CRUD helpers using auth
service=Service(globals())                   # for json, xml, jsonrpc, xmlrpc, amfrpc

mail.settings.server='localhost' if settings.production else 'logging'
mail.settings.sender=settings.sender
mail.settings.login=None
auth.settings.mailer=mail                    # for user email verification
auth.settings.registration_requires_verification = settings.production
auth.settings.registration_requires_approval = False
auth.messages.verify_email = 'Click on the link http://.../user/verify_email/%(key)s to verify your email'
